{% extends 'base.html' %}
{% load humanize %}
{% block page-content %}
{% include 'nav_cat_bar.html' %}
{% load mytags %}

<link href="/static/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
<link href="/static/css/plugins/dataTables/dataTables.responsive.css" rel="stylesheet">
<link href="/static/css/plugins/dataTables/dataTables.tableTools.min.css" rel="stylesheet">

<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>游戏服和配置文件选择</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li><a href="#">Config option 1</a>
                            </li>
                            <li><a href="#">Config option 2</a>
                            </li>
                        </ul>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <div class="row">
                        <div class="col-sm-4 m-b-xs">
                            <a  class="btn btn-primary btn-write" href="?project={{project}}&game_type=正式服&platform={{platform}}&area={{area_name}}"> 正式服</a>
                            <a  class="btn btn-primary btn-write" href="?project={{project}}&game_type=测试服&platform={{platform}}&area={{area_name}}"> 测试服</a>
                            <a  class="btn btn-primary btn-write" href="?project={{project}}&game_type=提审服&platform={{platform}}&area={{area_name}}"> 提审服</a>
                        </div>
                    </div>

                    <div class="table-responsive">
                        <form id="contents_form" name="contents_form">
                            <table class="table table-hover table-bordered dataTables-example">
                                <thead>
                                  <tr class="">
                                    <th class="text-center"><input id="checkall" type="checkbox" class="i-checks" name="checkall" value="checkall" data-editable='false' onclick="check_all('contents_form')"></th>
                                    <th class="text-center">地区</th>
                                    <th class="text-center">平台</th>
                                    <th class="text-center">区服名称</th>
                                    <th class="text-center">服务器IP</th>
                                    <th class="text-center">游戏服目录</th>
                                    <th class="text-center">服务器用途</th>
                                    <th class="text-center">游戏服ID</th>
                                    <th class="text-center">上一次状态监控时间</th>
                                    <th class="text-center">区服状态</th>
                                  </tr>
                                </thead>
                                <tbody>
                                  {% for num in game_info %}
                                    <tr class="text-center">
                                      <td>
                                          {{forloop.counter}}.<input type="checkbox"  name="subcheck"  value={{num.use.use_name}}+{{num.app_dir}}+{{num.server_id}}+{{num.p_ip}}>
                                      </td>
                                      <td>{{num.area.area_name}}</td>
                                      <td>{{num.platform.plat_name}}</td>
                                      <td>{{num.server_name}}</td>
                                      <td>{{num.p_ip}}</td>
                                      <td>{{num.app_dir}}</td>
                                      <td>{{num.use.use_name}}</td>
                                      <td>{{num.server_id}}</td>
                                      {% ifequal num.check_time|date:"Y-m-d H:i:s"|status_diff 1 %}
                                        <td><font color="green">{{num.check_time|date:"Y-m-d H:i:s"}}</font></td>
                                      {% else %}
                                        <td><font color="red">{{num.check_time|date:"Y-m-d H:i:s"}}</font></td>
                                      {% endifequal %}
                                      {% ifequal num.status 1 %}
                                        <td><font color="green">开启</font></td>
                                      {% else %}
                                        <td><font color="red">关闭</font></td>
                                      {% endifequal %}
                                    </tr>
                                  {% endfor %}
                                </tbody>
                            </table>

                            <div class="hr-line-dashed"></div>
                            <p><b><font color="red">请选择需要更新的配置文件: *</font></b></p>
                            {% for num in config_info %}
                              <input type="checkbox" name="filename" value={{num.name}}>{{num.name}}
                            {% endfor %}
                            <div class="hr-line-dashed"></div>
                        </form>
                        <button type="button" class="btn btn-primary dim" data-toggle="modal" data-target="#comfire_conf" data-whatever="@mdo" onclick="game_open()">更新配置文件</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" role="dialog" aria-labelledby="gridSystemModalLabel" id="comfire_conf">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="gridSystemModalLabel" align="center">服务端配置文件更新</h4>
        </div>
        <div class="modal-body">
        <div class="container-fluid" align="center">
            <p id="open_list"></p>
        </div>
        </div>
        <div class="modal-footer">
            <button type="submit" class="btn btn-primary dim" form="contents_form" formmethod="post" formaction="/inc/update_config_status/?area={{area_name}}&platform={{platform}}">确定</button>
            <button type="button" class="btn btn-info dim" data-dismiss="modal">关闭</button>
        </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<script src="/static/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="/static/js/plugins/dataTables/dataTables.bootstrap.js"></script>
<script src="/static/js/plugins/dataTables/dataTables.responsive.js"></script>
<script src="/static/js/plugins/dataTables/dataTables.tableTools.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('.dataTables-example').dataTable({
            responsive: true,
            "dom": 'T<"clear">lfrtip',
            "iDisplayLength":25,
            "tableTools": {
                "aButtons":["copy","xls",'print'],
                "sSwfPath": "/static/js/plugins/dataTables/swf/copy_csv_xls_pdf.swf"
            }
        });
    });
</script>
{%endblock%}